<?php foreach($list as $v){?>
<li class="list-item">
    <div>
        <img src="<?php echo $v['user_head']?>" class="head-img"/>
        <div class="item-text">
            <p class="p1 clearfix">
                <span class="fl"><?php echo $v['user_name']?></span>
                <?php if($first){?>
                <span class="fr" style="color: green">楼主采纳答案</span>
                <?php }?>
                <?php if(($type==2)&&($topic_info['status']==1)&&(session('user_info')['userid']==$topic_info['author'])){?>
                <span class="fr"><button onclick="adopt(<?php echo $v['id']?>)" class="adopt">采纳</button></span>
                <?php }?>
            </p>
            <p class="p2">
                <?php echo $v['content']?>
            </p>
            <p class="p3">
                <span class="span1"><?php echo $v['add_time']?></span>
                <span class="span2">
				    <a href="#"  <?php if(is_comment_appreciate($v['id'])){?> class="active" <?php }?>onclick="appreciate(<?php echo $v['id']?>,this)" ><i class="appreciate_sum<?php echo $v['id']?>"><?php echo $v['appreciate']?></i><i class="iconfont icon-dianzan"></i></a>
<!--				    <a href="#" ><i class="iconfont icon-pinglun1"></i></a>-->
				</span>
            </p>
        </div>
    </div>
</li>
<?php }?>
<script>
    function appreciate(id,obj) {
        if(obj.className=='active'){
            var type =2;
        }else{
            var type =1
        }
        var sum = parseInt($(obj).find('i').html());
        $.ajax({
            url:'<?php echo url('comment/comment_appreciate')?>',
            data:{
                id:id,
                type:type,
            },
            success:function (data) {
                if(type ==1){
                    obj.setAttribute('class','active');
                    $('.appreciate_sum'+id).html(sum+1);
                }else{
                    obj.setAttribute('class','');
                    $('.appreciate_sum'+id).html(sum-1);
                }

                layer.msg(data.msg);
            }
        })
    }

    function adopt(comment_id) {
        layer.msg('请稍等');
        var loading = layer.load(1, {shade: [0.4, '#000']}); //0代表加载的风格，支持0-2
        $.ajax({
            url:'<?php echo url("travel/adopt")?>',
            data:{
                comment_id:comment_id,
                topic_id:<?php echo $topic_info['id']?>,
            },
            success:function (data) {
                layer.msg(data.msg);
                setTimeout(function () {
                    layer.closeAll();
                    location.reload();
                }, 1000);
            }
        })
    }
</script>